import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserCardCompanyInfoVO, UserCardCompanyInfoForm, UserCardCompanyInfoQuery } from '@/api/goods/userCardCompanyInfo/types';

/**
 * 查询租户名片列表
 * @param query
 * @returns {*}
 */

export const listUserCardGoods = (query?: UserCardCompanyInfoQuery): AxiosPromise<UserCardCompanyInfoVO[]> => {
  return request({
    url: '/order/userCardGoods/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询租户名片详细
 * @param id
 */
export const getUserCardCompanyInfo = (id: string | number) => {
  return request({
    url: '/system/userCardCompanyInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增租户名片
 * @param data
 */
export const addUserCardGoods = (data: UserCardCompanyInfoForm) => {
  return request({
    url: '/order/userCardGoods',
    method: 'post',
    data: data
  });
};

/**
 * 修改租户名片
 * @param data
 */
export const editCompanyInfo = (data) => {
  return request({
    url: '/system/tenant/editCompanyInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除租户名片
 * @param id
 */
export const delUserCardGoods = (id: string | number | Array<string | number>) => {
  return request({
    url: '/order/userCardGoods/' + id,
    method: 'delete'
  });
};

export default {
  list: listUserCardGoods,
  get: getUserCardCompanyInfo,
  add: addUserCardGoods,
  update: editCompanyInfo,
  del: delUserCardGoods,
}